<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class MY_Controller extends MX_Controller {

function __construct()
{
	parent::__construct();	
	
			// define clean self-instances
			// for cleaner coding only
			$this->PACKAGE = clone $this;
			$this->PACKAGE->core = clone $this;//core package!!!
			$this->MODULE = clone $this;
			$this->DRIVER = clone $this;
			$this->APPLICATION = clone $this;
			

            /*
            *  ********************************************
            *  LOAD SETTINGS PACKAGE
            *  ********************************************
            */        
            // include settings package
            $this->load->add_package_path('packages/core');
        
            // load settings library from settings package			
			// NOTE: in this stage you cannot use clean package instances
			// like $this->package->library->method() because that functionality
			// is provided by Add() method which is defined in "packages" library
			// loaded below !!!
            $this->PACKAGE->core->load->library('settings');
			$this->PACKAGE->core->load->library('packages');

			// example of usage of the libraries loaded above:
			// $this->settings->method();
			// $this->packages->method();
			
			/*
			*  ***************************************************************
			*  LOAD SECURITY PACKAGE
			*  example of usage $this->security->load->library('app_modules');
            *  ***************************************************************
			*/
			// add security package
			$this->PACKAGE->core->packages->add('security');
			
			// load library  from security package by using clean package instance
			$this->PACKAGE->security->load->library('app_modules');			
			

			/*
			*  ***************************************************************
			*  LOAD ERRORS PACKAGE
			*  example of usage $this->errors->load->library('error_reporting');
            *  ***************************************************************
			*/
			// add security package
			$this->packages->add('errors');
			
			// load libraries from errors package by using clean package instances
			$this->PACKAGE->errors->load->library('generate');
			$this->PACKAGE->errors->load->library('texts');
            
            /*
             * ********************************************
             * THEME SETTINGS COMMON FOR ALL APPLICATIONS!!!
             * this method defines the following constants
             * 
             * 1) LANGUAGE
             * 2) THEME_PATH
             * 3) JS_PATH
             * 4) CSS_PATH
             * 5) IMG_PATH
             * 6) SITE_URL
             * ********************************************
             */            
            
            /*
             * ********************************************
             * RUN CORE THEME SETUP
			 * by runing settings library defined in 
			 * settings package
             * ********************************************
             */
            $this->PACKAGE->core->settings->set_core_theme();
            
            
            
            /*
             * ********************************************
             * LOAD LANGUAGE FILES COMMON FOR ALL MODULES!!!
             * ********************************************
             */
            $this->lang->load('texts',LANGUAGE);

}  

}